<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>获知连接是否为忙</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.pg-connection-busy" class="refentry">
   <div class="refnamediv">
    <h1 class="refname">pg_connection_busy</h1>
    <p class="verinfo">(PHP 4 &gt;= 4.2.0, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">pg_connection_busy</span> &mdash; <span class="dc-title">
     获知连接是否为忙
    </span></p>

   </div>
   <div class="refsect1 unknown-unknown-returnvalueu" id="refsect1-function.pg-connection-busy-unknown-unknown-returnvalueu">
    <h3 class="title">说明</h3>
    <div class="methodsynopsis dc-description">
     <span class="methodname"><strong>pg_connection_busy</strong></span>
      ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$connection</code></span>
     ) : <span class="type">bool</span></div>

    <p class="para rdfs-comment">
     <span class="function"><strong>pg_connection_busy()</strong></span> 在此连接状态为忙的时候返回 <strong><code>TRUE</code></strong>。如果连接状态为忙，说明前一个查询仍然在执行。如果调用 <span class="function"><a href="pg_get_result.html" class="function">pg_get_result()</a></span> 函数的话，则会被锁死。
    </p>
    <p class="para">
     <div class="example" id="example-2475">
      <p><strong>Example #1 <span class="function"><strong>pg_connection_busy()</strong></span> 例子</strong></p>
      <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;&nbsp;$dbconn&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">"dbname=publisher"</span><span style="color: #007700">)&nbsp;or&nbsp;die(</span><span style="color: #DD0000">"Could&nbsp;not&nbsp;connect"</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$bs&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_connection_busy</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbconn</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">$bs</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'connection&nbsp;is&nbsp;busy'</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'connection&nbsp;is&nbsp;not&nbsp;busy'</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
      </div>

     </div>
    </p>
    <p class="para">
     参见 <span class="function"><a href="pg_connection_status.html" class="function">pg_connection_status()</a></span> 和 <span class="function"><a href="pg_get_result.html" class="function">pg_get_result()</a></span>。
    </p>
   </div>

  </div></div></div></body></html>